#include "../../include/PageLib/PageLib.h"
#include <iostream>
#include <chrono>

PageLib::PageLib(Configuration* conf)
:_pageLibPreprocess(conf)
{
    cout << "PageLib" << endl;
}
PageLib::~PageLib()
{
    cout << "~PageLib" << endl;
}
void PageLib::create()
{
    //计算时间
    auto start = std::chrono::high_resolution_clock::now();
    //生成逻辑
    _pageLibPreprocess.createPageList();
    _pageLibPreprocess.createOffsetLib();
    _pageLibPreprocess.createInvertIndexLib();
    //计算结束时间
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> duration = end - start;
    std::cout << "生成耗时: " << duration.count() << "秒" << std::endl;
}

void PageLib::store()
{
    _pageLibPreprocess.storePageLib("../data/pageLib.dat");
    _pageLibPreprocess.storeOffsetLib("../data/offsetLib.dat");
    _pageLibPreprocess.storeInvertLib("../data/invertindex.dat");
    
}